import java.time.Year;

public class Thoroughbred {
    private final String mother;
    private final String father;
    private final int birthyear;

    public Thoroughbred(String mother, String father, int birthyear) {
        if (mother == null || mother.trim().isEmpty()) {
            throw new IllegalArgumentException("Mother name cannot be null or empty");
        }
        if (father == null || father.trim().isEmpty()) {
            throw new IllegalArgumentException("Father name cannot be null or empty");
        }
        if (birthyear < 1800 || birthyear > Year.now().getValue()) {
            throw new IllegalArgumentException("Invalid birth year: " + birthyear);
        }
        
        this.mother = mother;
        this.father = father;
        this.birthyear = birthyear;
    }

    public int getCurrentAge() {
        int currentYear = Year.now().getValue();
        return currentYear - birthyear;
    }

    public String getFather() {
        return father;
    }

    public String getMother() {
        return mother;
    }

    @Override
    public String toString() {
       
        return "Thoroughbred{" +
               "mother='" + mother + "'" +
               ", father='" + father + "'" +
               ", birthyear=" + birthyear +
               ", currentAge=" + getCurrentAge() +
               '}';
    }
    public static void main(String[] args) {
        try {
            Thoroughbred horse = new Thoroughbred("Secretariat", "Bold Ruler", 2010);
            System.out.println(horse);
            System.out.println("Father: " + horse.getFather());
            System.out.println("Mother: " + horse.getMother());
            System.out.println("Current Age: " + horse.getCurrentAge());
        } catch (IllegalArgumentException e) {
            System.err.println("对象创建失败: " + e.getMessage());
        }
    }
}